<template>
  <el-table
      :data="tableData"
      style="width: 100%"
      :row-class-name="tableRowClassName">
    <el-table-column prop="name" label="姓名" />
    <el-table-column prop="username" label="昵称"/>
    <el-table-column prop="sex" label="性别" />
    <el-table-column prop="address" label="住址" />
    <el-table-column prop="phoneNumber" label="电话号码" />
    <el-table-column prop="degree" label="学历" />
  </el-table>
</template>

<script>
import {getUserList} from "@/utils/api";

export default {
  name: 'Teacher',
  data() {
    return {
      tableData: [],
    }
  },
  created() {
    this.show()
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex === 1) {
        return 'warning-row'
      } else if (rowIndex === 3) {
        return 'success-row'
      }
      return ''
    },
    show(){
      getUserList("ter").then(res => this.tableData = res.data)
    }
  },
}
</script>

<style>
.el-table .warning-row {
  --el-table-tr-bg-color: var(--el-color-warning-lighter);
}
.el-table .success-row {
  --el-table-tr-bg-color: var(--el-color-success-lighter);
}
</style>